import os
import cv2
dirs = ['work1','work2','work3','work4']

path = r".\work1\work2"
if os.path.exists(path):
    print("存在")
else:
    print("不存在，创建")
    os.mkdir(path)


for root, dirs, files in os.walk(path):
    print(root)
    print(dirs)
    print(files)
    for file in files:
        print(os.path.join(root, file))
        # 注意文件名中有中文字符串可能会报错
        img = cv2.imread(os.path.join(root, file))
        print(img)
        if img is None:
            print("img is None")
        cv2.imshow("img", img)
        cv2.waitKey(0)